<template>
  <p>Child..</p>
  <p>{{ count }}</p>
  <button @click="update">按钮</button>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "Child",
  props: {
    count: {
      type: Number,
      required: true,
    },
  },
  emits: ["setCount"],
  setup(props, context) {
    /*s
      props prop属性
      context 对象
        attrs 所有未声明接受的属性
        emit 触发自定义事件
    */
    console.log(props, context);
    console.log(props.count);
    console.log(this); // undefined

    const update = () => {
      context.emit("setCount");
    };

    return {
      update,
    };
  },
});
</script>

<style></style>
